<template>
    <div>
        <el-table ref="carTable" :data="carData" style="width: 100%" class-name="car-table"  @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="55" label="序号" />
          <el-table-column prop="12"  label="商品">
            <template #default="{ row }">
              <div class="tit-wrap">
                <img class="goodsPhoto" src="https://shadow.elemecdn.com/app/element/hamburger.9cf7b091-55e9-11e9-a976-7f4d0b07eef6.png" />
                <el-text line-clamp="2" class="info">
                    {{ row.title }} {{ row.category }}
                </el-text>
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="kuc" label="库存" width="80">
          </el-table-column>
          <el-table-column prop="address" label="销量" width="80"></el-table-column>
          <el-table-column prop="type" label="状态" width="100" />
          <el-table-column prop="address" align="center" label="操作" width="160">
            <template #default="{ row }">
                <el-button size="small" type="primary" link  @click="golink(row.id)">编辑</el-button>
                <el-button size="small" type="primary" link @click="visible = !visible">下架</el-button>
                <el-button size="small" type="danger"  link @click="visible = !visible">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
        <div class="pagewaper">
            <el-pagination
                v-model:current-page="currentPage1"
                :page-size="100"
                :small="small"
                :disabled="disabled"
                :background="background"
                layout="total, prev, pager, next"
                :total="1000"
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
            />
        </div>
        <comm-dialog v-model="visible" @onSubmit="delSubmit">
            <span>确定删除这些产品吗?</span>
        </comm-dialog>
    </div>
</template>
<script setup lang="ts">
import Breadcrumb from '@/pages/mall/components/BreadcrumbCom.vue'
import CommDialog from '@/pages/mall/components/CommDialog.vue'
import { reactive, ref,computed } from 'vue'
import { ElTable } from 'element-plus'
import { useRoute, useRouter } from 'vue-router';
import {navigateToRoute} from '@/utils/utils'
const router = useRouter()

const visible = ref(false)


interface cargoods {
  property: string
  num: string
  totalPrice: string | number
}
const carData = reactive([
  {
    title: '这里是产品标题这里是产品标题这里是产品标题产品标题这里是产品标题',
    category: '分类：年会员（优惠券十张）',
    type: '会员订单',
    price: '¥ 3333.00',
    num: 1,
    kuc:20,
    totalPrice: '333.00',
  },
  {
    title: '这里是产品标题这里是产品标题这里是产品标题产品标题这里是产品标题',
    category: '分类：年会员（优惠券十张）',
    type: '会员订单',
    price: '¥ 3333.00',
    num: 1,
    kucun:20,
    totalPrice: '333.00',
  },
  {
    title: '这里是产品标题这里是产品标题这里是产品标题产品标题这里是产品标题',
    category: '分类：年会员（优惠券十张）',
    type: '会员订单',
    price: '¥ 3333.00',
    num: 1,
    kucun:20,
    totalPrice: '333.00',
  },
  {
    title: '这里是产品标题这里是产品标题这里是产品标题产品标题这里是产品标题',
    category: '分类：年会员（优惠券十张）',
    type: '会员订单',
    price: '¥ 3333.00',
    num: 1,
    kucun:20,
    totalPrice: '333.00',
  },
  {
    title: '这里是产品标题这里是产品标题这里是产品标题产品标题这里是产品标题',
    category: '分类：年会员（优惠券十张）',
    type: '会员订单',
    price: '¥ 3333.00',
    num: 1,
    kucun:20,
    totalPrice: '333.00',
  },
  {
    title: '这里是产品标题这里是产品标题这里是产品标题产品标题这里是产品标题',
    category: '分类：年会员（优惠券十张）',
    type: '会员订单',
    price: '¥ 3333.00',
    kucun:20,
    num: 1,
    totalPrice: '333.00',
  },
  {
    title: '这里是产品标题这里是产品标题这里是产品标题产品标题这里是产品标题',
    category: '分类：年会员（优惠券十张）',
    type: '会员订单',
    kucun:20,
    price: '¥ 3333.00',
    num: 1,
    totalPrice: '333.00',
  },
])

const carTable = ref<InstanceType<typeof ElTable>>()
const multipleSelection = ref<cargoods[]>([])
  
const handleSelectionChange = (val: cargoods[]) => {
  console.log(val,'val')
  multipleSelection.value = val
}

const golink = (id) => {
    router.push({ path: '/member/mall/shopedit', query: { id } })
};
const delSubmit=()=>{
  // let selectedRows = carTable.value?.getSelectedRows(); // 使用可选链操作符来安全地访问  
  // console.log(selectedRows)
  console.log(multipleSelection.value,'11')
}
const onSubmitCar = () => {
  router.push('/mall/goods/order')
}

</script>
<style scoped lang="scss">


.car-table {
  margin-bottom: 10px;
  background-color: #fff;

  .goodsPhoto {
    width: 58px;
    height: 58px;
    background-color: #d9d9d9;
    border-radius: 4px;
  }

  .tit-wrap {
    display: flex;
    align-items: center;
    .info{
        padding-left: 16px;
        color: #021429;
        font-size: 14px;
        max-width: 500px;
    }

    span {
      font-size: 16px;
      color: #040724;
    }
  }

  .num-wrap {
    width: 78px;
  }

  .result-wrap {
    padding: 20px 30px 30px 20px;
    font-size: 16px;

    .del-both {
      margin-left: 20px;
    }

    .result {
      font-size: 16px;

      b {
        margin-right: 50px;
        font-size: 24px;
        color: $primary;
      }
    }

    .submit-btn {
      width: 120px;
    }
  }
}
.pagewaper{
    display: flex;
    justify-content: flex-end;
}
</style>
